﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CrossLayerCommunication;
using ExampleWebApplication.BLL;
using ExampleWebApplication.Models;

namespace ExampleWebApplication.Controllers
{
    public class HomeController : Controller
    {
        [HttpGet]
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Index(User user)
        {
            var executeServiceCalls = TaskService.GetTaskForToday()
                    .Merge(UserService.LogInUser(user));

            if (executeServiceCalls.WasSuccessful)
                return View("DaylyTasks", executeServiceCalls.Data);
            else
                return View(executeServiceCalls);
        }

        public ActionResult DaylyTasks()
        {
            var executeServiceCalls = TaskService.GetTaskForToday();

            return View(executeServiceCalls.Data);
        }
    }
}